package com.boyinet.activation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boyinet.activation.entity.SoftwareInfo;
import com.boyinet.activation.mapper.SoftwareInfoMapper;
import com.boyinet.activation.service.SoftwareInfoService;
import com.boyinet.activation.vo.SoftwareInfoVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class UserInfoServiceImpl extends ServiceImpl<SoftwareInfoMapper, SoftwareInfo> implements SoftwareInfoService {

    @Resource
    SoftwareInfoMapper userInfoMapper;


    @Override
    public Page<SoftwareInfo> listByPage( SoftwareInfoVO condition) {
        LambdaQueryWrapper<SoftwareInfo> wrapper = Wrappers.lambdaQuery(SoftwareInfo.class).like(StringUtils.isNotBlank(condition.getName()), SoftwareInfo::getName, condition.getName())
                .between(Objects.nonNull(condition.getMinCreateTime()), SoftwareInfo::getCreateTime, condition.getMinCreateTime(), condition.getMaxCreateTime());
        return userInfoMapper.selectPage(new Page<>(condition.getPage(), condition.getLimit()), wrapper);
    }
}
